package com.sky.mapper;


import com.sky.anotation.AllFull;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CategoryMapper {

	@Select("select * from category where type = #{type}")
	List<Category> list(Integer type);

	@Select("select count(*) from category")
	Integer total();

	List<Category> page(CategoryPageQueryDTO categoryPageQueryDTO);

	@AllFull(OperationType.UPDATE)
	@Update("update category set status = #{status}, update_time = #{updateTime}, update_user = #{updateUser} where id = #{id}")
	void setStatus(Category category);

	@AllFull(OperationType.INSERT)
	void add(Category category);

	@Delete("delete from category where id = #{id}")
	void deleteById(Long id);

	@AllFull(OperationType.UPDATE)
	void edit(Category category);

	@Select("select type from category where id = #{id}")
	Integer type(Long id);
}
